package cn.chengpengper.im.platform.common.session;

import cn.chengpengper.im.platform.common.model.constants.ImPlatformContants;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
/*@formatter:off*/

/**
 * ____________________
 * < 神兽护体，永无bug! >
 * --------------------
 *
 * @author huchengpeng
 * @version v1.0.0
 * @date 2024/11/23 17:23
 * @description Session Context
 */

/*@formatter:on*/

public class SessionContext {

    public static UserSession getSession() {
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = requestAttributes.getRequest();
        return (UserSession) request.getAttribute(ImPlatformContants.SESSION);
    }
}
